<!DOCTYPE html>
<html>
  <head>
    <title>Listing 6.15</title>
    <script type="text/javascript" src="../scripts/assert.js"></script>
    <link href="../styles/assert.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <script type="text/javascript">

      function MyArray() {}                                         //#1
      MyArray.prototype.length = 0;                                 //#1

      (function() {                                                 //#2
        var methods = ['push', 'pop', 'shift', 'unshift',
          'slice', 'splice', 'join'];

        for (var i = 0; i < methods.length; i++) (function(name) {
          MyArray.prototype[ name ] = function() {
            return Array.prototype[ name ].apply(this, arguments);
          };
        })(methods[i]);
      })();

      var mine = new MyArray();                                     //#3
      mine.push(1, 2, 3);
      assert(mine.length == 3,
             "All the items are on our sub-classed array.");
      assert(!(mine instanceof Array),
             "We aren't subclassing Array, though.");

    </script>
  </body>
</html>

